/*
 * @lc app=leetcode.cn id=268 lang=rust
 *
 * [268] 丢失的数字
 */

// @lc code=start
impl Solution {
    pub fn missing_number(nums: Vec<i32>) -> i32 {
        let mut ret = 0 as i32;
        for i in nums.iter().enumerate() {
            ret ^= (i.0 as i32 ^ i.1);
        }
        ret ^= 0^(nums.len() as i32);//这是因为ret初始值为0，因此需要再异或一次0
        ret
    }
}
// @lc code=end

